package cn.sowz.log.config;

import cn.sowz.log.aspectj.LogAspect;
import cn.sowz.log.prop.LogProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(LogProperties.class)
// 要求配置文件中有enabled属性，不存在时，默认为false，表示日志不生效。
@ConditionalOnProperty(name = "mvc.log.enabled", matchIfMissing = true)
// 扫描指定的包，实现各组件加载
@ComponentScan("cn.sowz.log")
public class LogAspectEnableAutoConfiguration {
    @Bean
    public LogProperties logProperties(){
        return new LogProperties();
    }

    @Bean
    public LogAspect logAspect(){
        return new LogAspect();
    }
}
